package com.yanghui.lingYueBot.core.coreDatabaseUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

public class GroupDatabaseUtil extends BaseDatabaseUtil {

    public static Vector<Long> getGroupList() throws SQLException {
        Vector<Long> returnValue = new Vector<>();
        String sql = "SELECT groupID FROM [Group]";
        PreparedStatement statement = getStatement(sql);
        ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()) {
            returnValue.add(resultSet.getLong(1));
        }
        statement.close();
        return returnValue;
    }

    public static void setGroupName(String name) throws SQLException {
        String sql = "UPDATE [Group] SET groupName = ?";
        PreparedStatement statement = getStatement(sql);
        statement.setString(1, name);
        statement.executeUpdate();
        statement.close();
    }

}
